﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Kugar.Core.WinForm;
using Kugar.Core.ExtMethod;

namespace Kugar.UI.WinForm
{
    public partial class ImageButton : RoundedControl
    {
        public ImageButton()
        {
            InitializeComponent();
        }


        private Image _normalImage = null;
        public Image NormalImage
        {
            set
            {
                _normalImage = value;
                this.BackgroundImage = value;
                this.Refresh();
            }
            get { return _normalImage; }
        }

        private Image _moveInImage = null;
        public Image MoveInImage
        {
            set
            {
                _moveInImage = value;
                this.Refresh();
            }
            get { return _moveInImage; }
        }

        private Image _mouseDownImage = null;
        public Image MouseDownImage
        {
            set
            {
                _mouseDownImage = value;
                this.Refresh();
            }
            get { return _mouseDownImage; }
        }

        //public override Font Font
        //{
        //    get
        //    {
        //        return label1.Font;
        //    }
        //    set
        //    {
        //        label1.Font = value;
        //    }
        //}

        //public override Color ForeColor
        //{
        //    get
        //    {
        //        return label1.ForeColor;
        //    }
        //    set
        //    {
        //        label1.ForeColor = value;
        //    }
        //}

        private string _text = "ImageButton";

        [Browsable(true)]
        public override string Text
        {
            get
            {
                return _text;
            }
            set
            {
                _text = value;

                label1.Text = _text;
            }
        }

        private void ImageButton_MouseEnter(object sender, EventArgs e)
        {
            this.BackgroundImage = MoveInImage;
        }

        private void ImageButton_MouseLeave(object sender, EventArgs e)
        {
            this.BackgroundImage = NormalImage;
        }

        private void ImageButton_MouseDown(object sender, MouseEventArgs e)
        {
            this.BackgroundImage = MouseDownImage;

        }

        private void ImageButton_MouseUp(object sender, MouseEventArgs e)
        {
            this.BackgroundImage = MoveInImage;
        }

        private void ImageButton_MouseClick(object sender, MouseEventArgs e)
        {
            this.BackgroundImage = MouseDownImage;
        }

        private void ImageButton_Resize(object sender, EventArgs e)
        {
            //MessageBox.Show("1");
            label1.AlignTo(this);
        }

        private void label1_Resize(object sender, EventArgs e)
        {
            //MessageBox.Show("2");
            label1.AlignTo(this);
        }

    }
}
